use ironrdp_pdu::rdp::client_info::*;

pub const CLIENT_INFO_BUFFER_UNICODE_WITHOUT_OPTIONAL_FIELDS_LEN: usize = 218;

pub const CLIENT_INFO_BUFFER_UNICODE: [u8; 398] = [
    0x09, 0x04, 0x09, 0x04, // code page
    0xb3, 0x43, 0x00, 0x00, // flags
    0x0a, 0x00, // domain size
    0x0c, 0x00, // user name size
    0x00, 0x00, // password size
    0x00, 0x00, // alternate shell size
    0x00, 0x00, // work dir size
    0x4e, 0x00, 0x54, 0x00, 0x44, 0x00, 0x45, 0x00, 0x56, 0x00, 0x00, 0x00, // domain
    0x65, 0x00, 0x6c, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x73, 0x00, 0x00, 0x00, // user name
    0x00, 0x00, // password
    0x00, 0x00, // alternate shell
    0x00, 0x00, // work dir
    0x02, 0x00, // client address family
    0x1e, 0x00, // client address size
    0x31, 0x00, 0x35, 0x00, 0x37, 0x00, 0x2e, 0x00, 0x35, 0x00, 0x39, 0x00, 0x2e, 0x00, 0x32, 0x00, 0x34, 0x00, 0x32,
    0x00, 0x2e, 0x00, 0x31, 0x00, 0x35, 0x00, 0x36, 0x00, 0x00, 0x00, // client address
    0x84, 0x00, // client dir size
    0x43, 0x00, 0x3a, 0x00, 0x5c, 0x00, 0x64, 0x00, 0x65, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x73, 0x00, 0x5c,
    0x00, 0x77, 0x00, 0x32, 0x00, 0x6b, 0x00, 0x33, 0x00, 0x5f, 0x00, 0x31, 0x00, 0x5c, 0x00, 0x74, 0x00, 0x65, 0x00,
    0x72, 0x00, 0x6d, 0x00, 0x73, 0x00, 0x72, 0x00, 0x76, 0x00, 0x5c, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x77, 0x00, 0x63,
    0x00, 0x6c, 0x00, 0x69, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x5c, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x62, 0x00,
    0x5c, 0x00, 0x77, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x33, 0x00, 0x32, 0x00, 0x5c, 0x00, 0x6f, 0x00, 0x62, 0x00, 0x6a,
    0x00, 0x5c, 0x00, 0x69, 0x00, 0x33, 0x00, 0x38, 0x00, 0x36, 0x00, 0x5c, 0x00, 0x6d, 0x00, 0x73, 0x00, 0x74, 0x00,
    0x73, 0x00, 0x63, 0x00, 0x61, 0x00, 0x78, 0x00, 0x2e, 0x00, 0x64, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x00,
    0x00, // client dir
    0xe0, 0x01, 0x00, 0x00, 0x50, 0x00, 0x61, 0x00, 0x63, 0x00, 0x69, 0x00, 0x66, 0x00, 0x69, 0x00, 0x63, 0x00, 0x20,
    0x00, 0x53, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x20, 0x00,
    0x54, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x05, 0x00,
    0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x61, 0x00, 0x63, 0x00, 0x69,
    0x00, 0x66, 0x00, 0x69, 0x00, 0x63, 0x00, 0x20, 0x00, 0x44, 0x00, 0x61, 0x00, 0x79, 0x00, 0x6c, 0x00, 0x69, 0x00,
    0x67, 0x00, 0x68, 0x00, 0x74, 0x00, 0x20, 0x00, 0x54, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc4, 0xff, 0xff,
    0xff, // TimezoneInfo
    0x00, 0x00, 0x00, 0x00, // session id
    0x01, 0x00, 0x00, 0x00, // performance flags
];

pub const CLIENT_INFO_BUFFER_ANSI: [u8; 301] = [
    0x09, 0x04, 0x09, 0x04, // code page
    0xa3, 0x43, 0x00, 0x00, // flags
    0x05, 0x00, // domain size
    0x06, 0x00, // user name size
    0x00, 0x00, // password size
    0x00, 0x00, // alternate shell size
    0x00, 0x00, // work dir size
    0x4e, 0x54, 0x44, 0x45, 0x56, 0x00, // domain
    0x65, 0x6c, 0x74, 0x6f, 0x6e, 0x73, 0x00, // user name
    0x00, // password
    0x00, // alternate shell
    0x00, // work dir
    0x02, 0x00, // client address family
    0x0f, 0x00, // client address size
    0x31, 0x35, 0x37, 0x2e, 0x35, 0x39, 0x2e, 0x32, 0x34, 0x32, 0x2e, 0x31, 0x35, 0x36, 0x00, // client address
    0x42, 0x00, // client dir size
    0x43, 0x3a, 0x5c, 0x64, 0x65, 0x70, 0x6f, 0x74, 0x73, 0x5c, 0x77, 0x32, 0x6b, 0x33, 0x5f, 0x31, 0x5c, 0x74, 0x65,
    0x72, 0x6d, 0x73, 0x72, 0x76, 0x5c, 0x6e, 0x65, 0x77, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x6c, 0x69, 0x62,
    0x5c, 0x77, 0x69, 0x6e, 0x33, 0x32, 0x5c, 0x6f, 0x62, 0x6a, 0x5c, 0x69, 0x33, 0x38, 0x36, 0x5c, 0x6d, 0x73, 0x74,
    0x73, 0x63, 0x61, 0x78, 0x2e, 0x64, 0x6c, 0x6c, 0x00, // client dir
    0xe0, 0x01, 0x00, 0x00, 0x50, 0x00, 0x61, 0x00, 0x63, 0x00, 0x69, 0x00, 0x66, 0x00, 0x69, 0x00, 0x63, 0x00, 0x20,
    0x00, 0x53, 0x00, 0x74, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x20, 0x00,
    0x54, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x05, 0x00,
    0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x61, 0x00, 0x63, 0x00, 0x69,
    0x00, 0x66, 0x00, 0x69, 0x00, 0x63, 0x00, 0x20, 0x00, 0x44, 0x00, 0x61, 0x00, 0x79, 0x00, 0x6c, 0x00, 0x69, 0x00,
    0x67, 0x00, 0x68, 0x00, 0x74, 0x00, 0x20, 0x00, 0x54, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc4, 0xff, 0xff,
    0xff, // TimezoneInfo
    0x00, 0x00, 0x00, 0x00, // session id
    0x01, 0x00, 0x00, 0x00, // performance flags
];

lazy_static::lazy_static! {
    pub static ref CLIENT_INFO_UNICODE: ClientInfo = ClientInfo {
        code_page: 0x0409_0409,
        flags: ClientInfoFlags::MOUSE
            | ClientInfoFlags::DISABLE_CTRL_ALT_DEL
            | ClientInfoFlags::UNICODE
            | ClientInfoFlags::MAXIMIZE_SHELL
            | ClientInfoFlags::COMPRESSION
            | ClientInfoFlags::ENABLE_WINDOWS_KEY
            | ClientInfoFlags::FORCE_ENCRYPTED_CS_PDU,
        compression_type: CompressionType::K64,
        credentials: Credentials {
            username: String::from("eltons"),
            password: String::from(""),
            domain: Some(String::from("NTDEV"))
        },
        alternate_shell: String::from(""),
        work_dir: String::from(""),
        extra_info: ExtendedClientInfo {
            address_family: AddressFamily::INet,
            address: String::from("157.59.242.156"),
            dir: String::from("C:\\depots\\w2k3_1\\termsrv\\newclient\\lib\\win32\\obj\\i386\\mstscax.dll"),
            optional_data: ExtendedClientOptionalInfo::builder()
                .timezone(TimezoneInfo {
                    bias: 0x01e0,
                    standard_name: String::from("Pacific Standard Time"),
                    standard_date: OptionalSystemTime(Some(SystemTime {
                        month: Month::October,
                        day_of_week: DayOfWeek::Sunday,
                        day: DayOfWeekOccurrence::Last,
                        hour: 2,
                        minute: 0,
                        second: 0,
                        milliseconds: 0,
                    })),
                    standard_bias: 0,
                    daylight_name: String::from("Pacific Daylight Time"),
                    daylight_date: OptionalSystemTime(Some(SystemTime {
                        month: Month::April,
                        day_of_week: DayOfWeek::Sunday,
                        day: DayOfWeekOccurrence::First,
                        hour: 2,
                        minute: 0,
                        second: 0,
                        milliseconds: 0,
                    })),
                    daylight_bias: 0xffff_ffc4,
                })
                .session_id(0)
                .performance_flags(PerformanceFlags::DISABLE_WALLPAPER)
                .build(),
        },
    };

    pub static ref CLIENT_INFO_ANSI: ClientInfo = {
        let mut client_info = CLIENT_INFO_UNICODE.clone();
        client_info.flags -= ClientInfoFlags::UNICODE;
        client_info
    };

    pub static ref CLIENT_INFO_UNICODE_WITHOUT_OPTIONAL_FIELDS: ClientInfo = {
        let mut client_info = CLIENT_INFO_UNICODE.clone();
        client_info.extra_info.optional_data = ExtendedClientOptionalInfo::default();
        client_info
    };

    pub static ref CLIENT_INFO_BUFFER_UNICODE_WITHOUT_OPTIONAL_FIELDS: Vec<u8> = {
        let mut buffer = CLIENT_INFO_BUFFER_UNICODE.to_vec();
        buffer.truncate(CLIENT_INFO_BUFFER_UNICODE_WITHOUT_OPTIONAL_FIELDS_LEN);
        buffer
    };
}
